package com.new4net.exe_stream.meta.impl;

import com.new4net.exe_stream.instruction.impl.ExecutionInstruction;
import com.new4net.exe_stream.listener.impl.ExecutionLogListener;
import com.new4net.exe_stream.meta.ExecutionContext;
import com.new4net.exe_stream.service.ExecutionInstructionService;

public class SimpleExecutionStatement extends AbstractExecutionStatement<ExecutionInstruction> {

    public SimpleExecutionStatement(String name, ExecutionContext context) {
        super(name, context);
    }

    @Override
    public ExecutionInstruction _end() {
        executionInstruction.setExecutionContext(context);
        executionInstruction.getExecuteResult().setStatus("READY");
        // 托管instruction
        ExecutionInstructionService executionInstructionService = context.getExecutionInstructionService();
        if(executionInstructionService!=null){
            executionInstructionService.hosting(executionInstruction);

        }
        executionInstruction.addInstructionListener(new ExecutionLogListener());
        return executionInstruction;
    }
}
